import argparse, flask, os, sys
dir = os.path.abspath('..')
sys.path.append(dir)
# ssh连接回馈状态
from main.tools.setHttpOrganization import after_request

api = flask.Flask(__name__)
api.after_request(after_request)

# 设置脚本输入参数
parser = argparse.ArgumentParser(description='argparse testing')
parser.add_argument('--e', '-e', type=str, help="ssh状态")
parser.add_argument('--outport', '-o', type=int, help="OutPort")
args = parser.parse_args()

@api.route('/sshstatus', methods=['get'])
def status():
    if (args.e.__str__() == "201"):
        return "201" # 密码错误
    elif (args.e.__str__() == "200"):
        return "200"
    else:
        return "500" # 其他情况
if __name__ == '__main__':
    api.run(port=args.outport-1, debug=False, host='127.0.0.1')
